#include "main/utils.h"
using namespace std;

int minProductLen(const vector<int> &vec, const int &k) {
  int count = 0;
  int begin = 0, end = 0;
  int cur_product = vec[0];
  while (begin <= end && end < vec.size()) {
    if (cur_product < k) {
      cur_product *= vec[++end];
      count += (end - begin);
    } else {
      cur_product /= vec[begin++];
    }
  }
  return count;
}

int main() {
  vector<int> vec = {10, 5, 2, 6};
  int k = 100;
  int ret = minProductLen(vec, k);
  cout << "The minimum length of sub array which product less than k: " << ret << endl;

  return 0;
}
